package com.xh.petdogexpert.expert.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xh.petdogexpert.base.ResponseData;
import com.xh.petdogexpert.expert.dto.JudgeLog;
import com.xh.petdogexpert.expert.service.IJudgeLogService;

@RequestMapping(value = "/expert")
@Controller
public class JudgeLogController {

	@Autowired
	IJudgeLogService judgeLogService;

	@Autowired
	HttpSession session;

	/**
	 * 返回登陆者的全部诊断过程信息
	 * 
	 * @author linxixin
	 * @date 2016年4月11日
	 */
	@RequestMapping(value = "/getMyJudgeLogs")
	@ResponseBody
	public ResponseData getMyJudgeLogs(@RequestParam(defaultValue = "1") Integer pagenum,
			@RequestParam(defaultValue = "10") Integer pagesize) {
		List<JudgeLog> myJudgeLog = judgeLogService.getMyJudgeLogs(pagenum, pagesize);

		return new ResponseData(myJudgeLog);
	}

	@RequestMapping(value = "/getMyJudgeLog")
	@ResponseBody
	public ResponseData getMyJudgeLogs(Integer judgeLogId) {

		JudgeLog myJudgeLog = judgeLogService.getMyJudgeLog(judgeLogId);

		return new ResponseData(myJudgeLog);
	}

	@RequestMapping(value = "/updateMyJudgeLog")
	@ResponseBody
	public ResponseData updateMyJudgeLog(JudgeLog judgeLog) {

		int res = judgeLogService.updateMyJudgeLog(judgeLog);
		if (res != 0)
			return new ResponseData(true);
		else
			return new ResponseData(false);
	}
}
